package com.hdwx.weike.controllers;

import com.hdwx.weike.service.IVideoService;
import com.hdwx.weike.service.impl.VideoServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by hdwx on 2017/1/5.
 */
@WebServlet(urlPatterns = "/updateCollection.do")
public class ViewCountController extends BaseController{
    IVideoService videoService=new VideoServiceImpl();
    @Override
    public void todo(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("ViewCountController:更新浏览量！");
        String id = req.getParameter("v_id");
        int v_id=0;//默认0，无更新
        if(id!=null){
            try {
                v_id=Integer.valueOf(id);
            }catch (Exception e){}
        }
        boolean b = videoService.updateVideoCollection(v_id);
        if(b){
            System.out.println("ViewCountController:成功更新浏览量！"+v_id);
        }

    }
}
